<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * 后台管理页尾
 * @author 		jaypha
 * @qq			168007694
 * @email		psufool@163.com
 * @home page	www.psufool.cn
 */
class Head extends Admin_Controller{
	
	function __construct(){
		parent::__construct();
		$this->load->model('JayphaDB');
		if(is_null($this->adminCurrentTemplate) or empty($this->adminCurrentTemplate)){
			$this->adminCurrentTemplate = 'default';
		}
		$this->dbTablePrefix = $this->config->item('db_table_prefix');
	}
	
	function index(){
		if(!$this->noLoginErr()) return false;
		$data['systemTitle'] = $this->JayphaDB->getConfigValue('systemTitle');
		$data['checkAdminIsLogin'] = $this->JayphaDB->getConfigValue('checkAdminIsLogin');
		$data['adminUserName'] = $this->session->userdata('adminUserName');
		$tvName = 'admin_menu';
		$where = array(
				'disabled'=>false,
				'parentId'=>0
		);
		$order = 'oIndex,id';
		$data['menuList'] = $this->JayphaDB->getDB(0,0,'id,parentId,identifier,title,url',$this->dbTablePrefix.$tvName,$where,'oIndex,id',true);
		$data['adminPermission'] = $this->JayphaDB->getAdminPermission($this->session->userdata('adminUserId'));
		for($i=0;$i<count($data['menuList']);$i++){
			$sub_where = array('disabled'=>false,'parentId'=>$data['menuList'][$i]->id);
			$menu_sub_list = $this->JayphaDB->getDB(0,0,'id,identifier,title',$this->dbTablePrefix.$tvName,$sub_where,'oIndex,id',true);
			$sub_num = 0;
			foreach($menu_sub_list as $sub_item){
				if(stristr($data['adminPermission'],$sub_item->identifier.':')) $sub_num++;
			}
			if($data['menuList'][$i]->id==3){
				$channel = $this->JayphaDB->getDB(0,0,'id,identifier,title',$this->dbTablePrefix.'channel',array('disabled'=>0),'id',true);
				foreach($channel as $channel_item){
					if(stristr($data['adminPermission'],$channel_item->identifier.':')) $sub_num++;
				}
				unset($channel);
			}
			$data['menuList'][$i]->sub_num = $sub_num;
			unset($sub_where);
			unset($menu_sub_list);
			unset($sub_num);
		}
		$this->load->view("admin/$this->adminCurrentTemplate/head",$data);
	}
}

/* End of file head.php */
/* Location: ./application/controllers/admin/head.php */